export default class InputVariable {
  constructor(variableValue, variableName = null) {
    this.variableValue = variableValue;
    this.variableName = variableName || null;
  }

  isVariable() {
    return !!this.variableName;
  }

  valueEquals(value, precision = 0) {
    const dif = Math.abs(value - this.variableValue);
    const tol = precision === 0 ? 0 : 1 / Math.pow(10, precision);
    return dif <= tol;
  }

  clone() {
    return new InputVariable(this.variableValue, this.variableName);
  }
}
InputVariable.prototype.isInputVariable = true;